package com.itheima.mapper;

import com.itheima.domain.Classes;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface ClassesMapper {
    @Select("select * from classes")
    @Results({
            @Result(column ="cid",property = "cid",id=true),
            @Result(column ="cname",property = "cname"),

            @Result(
                    property = "studentList",
                    javaType = List.class,//被包含的属性类型List
                    column = "cid",
                    many = @Many(select = "com.itheima.mapper.StudentMapper.findByCid",fetchType = FetchType.LAZY)
            )
    })
    List<Classes> findAll();
}
